package com.zm.demo.shoppingmall.gateway.service;

import com.zm.demo.shoppingmall.product.api.ProductService;
import com.zm.demo.shoppingmall.product.model.TProduct;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.stereotype.Component;

import java.time.LocalDateTime;

/**
 * @desc:
 * @author: z01140
 * @date: 2021/5/25 10:27
 */
@Component
public class ProductManager {

    @DubboReference
    private ProductService productService;

    public int addProduct(TProduct product){
        LocalDateTime now = LocalDateTime.now();
        product.setUpdateTime(now);
        product.setCreateTime(now);
        return productService.addProduct(product);
    }

    public int updateProduct(TProduct product){
        LocalDateTime now = LocalDateTime.now();
        product.setUpdateTime(now);
        return productService.updateProduct(product);
    }

    public int deleteProductById(int productId){
        return productService.deleteProuctByProductId(productId);
    }

    public TProduct getProductById(int productId){
        return productService.getProductById(productId);
    }

    public TProduct getProductByProductNo(String productNo){
        return productService.getProductByProductNo(productNo);
    }

}
